package com.springboot.wisdom.mqtt.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.github.xiaoymin.knife4j.annotations.ApiSupport;
import com.springboot.wisdom.common.common.bean.MyResult;
import com.springboot.wisdom.common.common.bean.PageQueryDTO;
import com.springboot.wisdom.mqtt.service.HardwareDeviceErrorService;
import com.springboot.wisdom.serviceApi.mqtt.model.vo.HardwareDeviceErrorVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

@Api(tags = "设备警告日志模块【设备管理】")
@ApiSupport(author = "LY L")
@RestController
@RequestMapping(value = "/device/error", produces = {"application/json;charset=UTF-8"})
@Slf4j
@Validated     // springboot 2.5.* 版本需要在类上标注 @Validated 注解校验注解才会生效。
public class HardwareDeviceErrorController {

    @Autowired
    private HardwareDeviceErrorService hardwareDeviceErrorService;


    @ApiOperation(value = "报警日志列表分页", notes = "")
    @GetMapping("/errorInfo/page")
    public MyResult<Page<HardwareDeviceErrorVO>> getInfoPageBy(PageQueryDTO pageQueryDTO, HardwareDeviceErrorVO vo) {
        return hardwareDeviceErrorService.getInfoPageBy(pageQueryDTO, vo);
    }

    @ApiOperation(value = "添加报警日志", notes = "")
    @PostMapping("/add")
    public MyResult<String> add(@RequestBody @Valid HardwareDeviceErrorVO vo) {
        return hardwareDeviceErrorService.add(vo);
    }
}
